<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="./css/login.css">
</head>

<body>
    <div class="zcy22001030403-shell">
        <div class="zcy22001030403-img-box">
            <img src="./img/login/login.jpg" alt="">
        </div>
        <form class="zcy22001030403-form" id="zcy22001030403-login-form" action="" method="post">
            <div class="zcy22001030403-form-body">
                <div class="zcy22001030403-welcome-lines">
                    <div class="zcy22001030403-w-line-1">欢迎来到billbill</div>
                </div>
                <div class="zcy22001030403-input-area">
                    <div class="zcy22001030403-f-inp">
                        <input type="text" id="zcy22001030403-username" placeholder="用户名">
                        <div id="zcy22001030403-username-error" class="zcy22001030403-error"></div>
                    </div>
                    <div class="zcy22001030403-f-inp">
                        <input type="password" id="zcy22001030403-password" placeholder="密码">
                        <div id="zcy22001030403-password-error" class="zcy22001030403-error"></div>
                    </div>
                </div>
                <div class="zcy22001030403-submit-button-cvr">
                    <button type="submit" class="zcy22001030403-submit-button" id="zcy22001030403-submit-button">登录</button>
                </div>
                <div class="zcy22001030403-forgot-pass">
                    <a href="#">Forgot password?</a>
                </div>
            </div>
        </form>
    </div>

    <script>
        document.getElementById('zcy22001030403-login-form').addEventListener('submit', function(event) {
        event.preventDefault(); 

        const username = document.getElementById('zcy22001030403-username').value.trim();
        const password = document.getElementById('zcy22001030403-password').value.trim();

        let isValid = true;

        document.getElementById('zcy22001030403-username-error').textContent = '';
        document.getElementById('zcy22001030403-password-error').textContent = '';
        document.getElementById('zcy22001030403-username').classList.remove('zcy22001030403-input-error', 'zcy22001030403-input-valid');
        document.getElementById('zcy22001030403-password').classList.remove('zcy22001030403-input-error', 'zcy22001030403-input-valid');

        const usernameRegex = /^(?:\d{11}|\w+([.-_]\w+)*@\w+([.-_]\w+)*\.[a-zA-Z]{2,})$/;
        if (username.length < 3 || !usernameRegex.test(username)) {
            document.getElementById('zcy22001030403-username-error').textContent = '用户名必须是手机号或电子邮箱，且不少于3个字符';
            document.getElementById('zcy22001030403-username').classList.add('zcy22001030403-input-error');
            isValid = false;
        } else {
            document.getElementById('zcy22001030403-username').classList.add('zcy22001030403-input-valid');
        }

        if (password.length < 3 || password.length > 16) {
            document.getElementById('zcy22001030403-password-error').textContent = '密码必须为3到16个字符';
            document.getElementById('zcy22001030403-password').classList.add('zcy22001030403-input-error');
            isValid = false;
        } else {
            document.getElementById('zcy22001030403-password').classList.add('zcy22001030403-input-valid');
        }

        if (isValid) {
            window.location.href = 'zcy22001030403-index.html';
        }
    });

    </script>
</body>

</html>
